<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <form action="https://www.baidu.com/s?">
    <input type="text" name="wd">
    <input type="submit" value="搜索">
  </form>
  <a href="http://www.baidu.com">百度一下</a>
  <script>
    const form = document.querySelector('form')
    form.addEventListener('submit', function (e) {
      // 阻止默认行为   提交 事件对象.preventDefault()
      alert(666666);
      e.preventDefault();
    })

    const a = document.querySelector('a')
    a.addEventListener('click', function (e) {
      // 阻止默认行为   提交 跳转
      alert(666666);
      e.preventDefault();
    })
  </script>
</body>

</html>